package com.kyivmohyla.kma2.client.view.common;

import com.google.gwt.cell.client.NumberCell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.HasData;
import com.kyivmohyla.kma2.shared.model.UIService;

public class ServiceCellTableWidget extends Composite {

    private final CellTable<UIService> serviceCellTable;

    public ServiceCellTableWidget() {
        serviceCellTable = new CellTable<UIService>();
        serviceCellTable.addColumn(new Column<UIService, Number>(new NumberCell()) {
            @Override
            public Number getValue(UIService object) {
                return object.getServiceId();  //To change body of implemented methods use File | Settings | File Templates.
            }
        }, "ID");
        serviceCellTable.addColumn(new Column<UIService, String>(new TextCell()) {
            @Override
            public String getValue(UIService object) {
                return object.getName();  //To change body of implemented methods use File | Settings | File Templates.
            }
        }, "Name");
        serviceCellTable.addColumn(new Column<UIService, String>(new TextCell()) {
            @Override
            public String getValue(UIService object) {
                return object.getDescription();  //To change body of implemented methods use File | Settings | File Templates.
            }
        }, "Description");
        initWidget(serviceCellTable);
    }

    public HasData getServiceCellTable() {
        return serviceCellTable;
    }

    public Widget asWidget() {
        return this;
    }
}
